﻿Public Class frmResaLigne
    Public pNoLigne As Integer

    Private szSQL As String
    Private rs As ADODB.Recordset

    Private Sub frmResaLigne_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        InitComboStatutsLecon(CB_STATUT)
        RdVToScreen()

    End Sub

    Private Sub RdVToScreen()
        Dim rsEleve As ADODB.Recordset = Nothing

        ' Lire le rendez-vous sélectionné
        szSQL = "CALL spGet_ELEVES_CPT_byNO_LIGNE(" & pNoLigne & ")"
        GetRecordset(ctDSN_AEM, szSQL, rs)
        If rs.RecordCount > 0 Then
            TE_CD_CLI.Text = rs.Fields("cd_cli").Value
            gCD_CLI = TE_CD_CLI.Text
            TE_DATE.Value = rs.Fields("date").Value
            TE_NOM.Text = nv(rs.Fields("nom").Value)
            ' Lire la fiche Eleves
            szSQL = "CALL spGet_ELEVES_byCD_CLI(" & TE_CD_CLI.Text & ")"
            GetRecordset(ctDSN_AEM, szSQL, rsEleve)
            If rsEleve.RecordCount > 0 Then
                TE_FORMULE.Text = nv(rsEleve.Fields("formule").Value)
                TE_OBS.Text = nv(rsEleve.Fields("obs").Value)
                rsEleve.Close()
            Else
                TE_FORMULE.Text = " "
                TE_OBS.Text = " "
            End If
            CB_STATUT.SelectedIndex = CB_STATUT.FindString(rs.Fields("statut").Value.ToString)
            TE_QTE.Text = rs.Fields("qte").Value
            TE_REF.Text = nv(rs.Fields("ref").Value)
            TE_INTITULE.Text = nv(rs.Fields("intitule").Value)
            TE_DEBIT.Text = rs.Fields("debit").Value.ToString & " €"
            TE_COMMENT.Text = nv(rs.Fields("comment").Value)
            TE_MODIFIE_LE.Text = setModifiedBy(rs.Fields("cree_le").Value, rs.Fields("modif_le").Value, rs.Fields("cd_uti").Value)
            TE_FIN_RESA.Text = IfDate(rs.Fields("fin_reservation").Value)
        End If
        rs.Close()
        Me.Text = "RESERVATION - " & TE_DATE.Text

    End Sub

    Private Sub BO_ELEVE_Click(sender As System.Object, e As System.EventArgs) Handles BO_ELEVE.Click
        gCD_CLI = TE_CD_CLI.Text
        If IsEleve(gCD_CLI) Then
            frmElevesMAJ.ShowDialog()
        End If

    End Sub
End Class